package com.zb.automation.util;

import com.zb.automation.common.Constant;

import java.util.Random;

/**
 * @Description
 * @Author ZhangBin
 * @Data 2022/7/24 15:47
 */
public class StringUtils {


    /**
     * @Author ZhangBin
     * @Date 2022/7/23 14:01
     * @Description 获取指定范围的随机数字
     */
    public static int getRandom(int min, int max) {
        return new Random().nextInt(max) % (max - min + 1) + min;
    }

    /**
     * @Author ZhangBin
     * @Date 2022/7/23 14:01
     * @Description 获取指定长度的随机数字
     */
    public static int getRandomFixLen(int len){
        String maxStr = "";
        String minStr = "";
        for(int i=0;i<len;i++){
            maxStr+="9";
            if(i == 0){
                minStr+="1";
            }else{
                minStr+="0";
            }
        }
        int max = new Integer(maxStr);
        int min = new Integer(minStr);
        return new Random().nextInt(max) % (max - min + 1) + min;
    }

    /**
     * @Author ZhangBin
     * @Date 2022/7/23 14:01
     * @Description 括号包裹
     */
    public static String bracketsPackage(String str,String ifEmptyReplaceStr){
        if(org.apache.commons.lang3.StringUtils.isEmpty(str)){
            str = ifEmptyReplaceStr;
        }
        return Constant.LEFT_BRACKETS + str + Constant.RIGHT_BRACKETS;
    }

}
